package br.com.condominio.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Transient;

@Entity
@SequenceGenerator(name = "residencial_res_codigo_seq", sequenceName = "residencial_res_codigo_seq", allocationSize = 1)
public class Residencial implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer resCodigo;
	private String resNome;
	private String resCnpj;

	private boolean active = false;

	public Residencial() {
		super();
	}

	public Residencial(Integer resCodigo, String resNome) {
		this.resCodigo = resCodigo;
		this.resNome = resNome;
	}

	public Residencial(Integer resCodigo, String resNome, String resCnpj) {
			
		this.resCodigo = resCodigo;
		this.resNome = resNome;
		this.resCnpj = resCnpj;
	}

	@Id
	@Column(name = "res_codigo", unique = true, nullable = false, precision = 131089, scale = 0)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "residencial_res_codigo_seq")
	public Integer getResCodigo() {
		return this.resCodigo;
	}

	public void setResCodigo(Integer resCodigo) {
		this.resCodigo = resCodigo;
	}

	@Column(name = "res_nome", nullable = false)
	public String getResNome() {
		return this.resNome;
	}

	public void setResNome(String resNome) {
		this.resNome = resNome;
	}

	@Column(name = "res_cnpj", precision = 20, scale = 0)
	public String getResCnpj() {
		return this.resCnpj;
	}

	public void setResCnpj(String resCnpj) {
		this.resCnpj = resCnpj;
	}

	@Transient
	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((resCodigo == null) ? 0 : resCodigo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Residencial other = (Residencial) obj;
		if (resCodigo == null) {
			if (other.resCodigo != null)
				return false;
		} else if (!resCodigo.equals(other.resCodigo))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Residencial [resCodigo=" + resCodigo + ", resNome=" + resNome
				+ ", resCnpj=" + resCnpj + "]";
	}

}
